package com.xin.springclouduser.converter;

import com.xin.springclouduser.dataobject.User;
import com.xin.springclouduser.dto.UserDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class UserDTO2UserConverter {

    public static User convert(UserDTO userDTO) {
        User user = new User();
        BeanUtils.copyProperties(userDTO, user);
        return user;
    }

    public static List<User> convert(List<UserDTO> userDTOS){
         return userDTOS.stream().map(e -> convert(e)).collect(Collectors.toList());
    }

}
